(function() {
    'use strict';
    var $form=$("form");
    var $department=$(".department");
    var $roleName=$(".roleName");
    $form.validate({
        /**
         * ignore：忽略某些元素不验证
         * @type {String}
         * 例如：ignore: ".ignore" ，忽略所有的带ignore class 的标签
         */
        ignore: ".ignore"
    });
    window.formObject = $form;
    var userInfo=common.getLocalData(common.agentSysCacheWord).user;
    //初始化 职务列表
    common.buildInitSelect($roleName);
    //创建 部门的下拉列表，并联动根据当前部门获取职务列表
    buildSelect.buildRoleListByDepartment({
        departmentSelector:$department,
        roleSelector:$roleName
    });
    // var record={
    //     coverPhoto:""
    // };
    var headerPhotoGallery=$("#header-photo").gallery({
        readOnly:false,
        title:"上传用户头像",
        url:window.globalHost +common.uploadImagePort,
        paramName:"uploadData",
        fileFolder:{folder:"user",id:userInfo.id,fileName:"sys_user_"+new Date().getTime()},
        returnPathName:"filePath",
        maxFiles:1,
        filePaths:[],
        uploadCallback:function () {
            var path=headerPhotoGallery.getFilePaths();
            $("#photo").val(!!path.length?path.join(","):"")
        },
        deleteCallback:function () {
            var path=headerPhotoGallery.getFilePaths();
            $("#photo").val(!!path.length?path.join(","):"");
        }
    });
}).call(this);
